<template>
    <div class="homeDiv">
        <div class="homeDiv-box">
            <el-avatar :size="80" :src="userInfo.avatar" />
            <h1 class="homeDiv-name">{{ (userInfo.greetings!) + userInfo.username }}</h1>
        </div>
        <img class="homeDiv-img" src="../../assets/images/home1.svg" />
    </div>
</template>

<script setup lang="ts">
import { onMounted, reactive } from 'vue';
import { useStoreUser } from '@/store/modules/user';
import { getTimeWord } from '@/utils/time';

interface userType {
    username?: string | null,
    avatar?: string | undefined,
    greetings?: string,
}

const userStore = useStoreUser();

let userInfo: userType = reactive({
    username: '',
    avatar: '',
    greetings: getTimeWord(),
})

onMounted(() => {
    userInfo.username = userStore.username;
    userInfo.avatar = userStore.avatar;
})
</script>

<style scoped lang="scss">
.homeDiv{
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;

    &-box{
        width: 100%;
        height: 150px;
        border-radius: 8px;
        box-shadow: 0px 0.5px 3px 1px #d8d6d6;
        display: flex;
        align-items: center;
        padding-left: 20px;
    }

    &-name {
        padding-left: 20px;
        font-size: 25px;
        font-weight: 700;
    }
    
    &-img{
        width: 500px;
        height: 500px;

    }
}
</style>